package com.ttwm.dao;

import com.ttwm.pojo.Order;
import com.ttwm.pojo.OrderFood;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface OrderFoodDao {

    @Select("select * from t_orderfind where orderIds=#{orderId}")
    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(id = true,property = "foodIds",column = "foodIds"),
            @Result(property = "food",column = "foodIds",
                    one = @One(select = "com.ttwm.dao.FoodDao.foods"))
    })
    List<OrderFood> allOrderFood(OrderFood orderFood);

    @Insert("insert into t_orderfind(orderIds,foodIds,sum,total) values (#{orderIds},#{foodIds},#{sum},#{total})")
    int insetOrderFood(OrderFood orderFood);

    @Delete(" delete from t_orderfind where id=#{id}")
    int deleteOrderFood(OrderFood orderFood);

    //    修改total
    @Update("update t_orderfind set sum=#{sum},total=#{total} where id=#{id}")
    int updateSumTotal(OrderFood orderFood);
}
